package com.chhuang.utils.string;

import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;

import com.chhuang.utils.Assert;
/**
 * 
* @ClassName: UrlCoderUtil 
* @Description: TODO 
* @author: 黄晨 
* @date: 2015-3-25
*
 */
public class UrlCoderUtil {
	private UrlCoderUtil(){}
	/**
	 * url编码
	 * @param arg0
	 * @param charset
	 * @return
	 */
	public static String UrlEncode(String arg0,String charset){
		if(Assert.isValidString(arg0)){
			try {
				return URLEncoder.encode(arg0, charset);
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return arg0;
	}
	/**
	 * url解码
	 * @param arg0
	 * @param charset
	 * @return
	 */
	public static String UrlDecode(String arg0,String charset){
		if(Assert.isValidString(arg0)){
			try {
				return URLDecoder.decode(arg0, charset);
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
		}
		return arg0;
	}
}
